package com.bdqn.t330.ch01.controller;

import com.bdqn.t330.ch01.entity.User;
import com.bdqn.t330.ch01.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

@Controller
public class HelloController {

    @Autowired
    private UserService userService;

    @Value("${com.ktjiaoyu.id}")
    private int id;
    @Value("${com.ktjiaoyu.name}")
    private String name;
    @Value("${com.ktjiaoyu.age}")
    private int age;

    @Resource
    private User lisi;


    @ResponseBody
    @RequestMapping(path = "/hello")
    public Object hello(String name) {
        System.out.println("name:" + name);
        return "你好:" + name;
    }

    @ResponseBody
    @RequestMapping(path = "/list")
    public Object list() {
        return userService.getUserListBiz();
    }

    @ResponseBody
    @RequestMapping(path = "/user")
    public Object user() {
        //User user = new User(id,name,age);
        return lisi;
    }
}
